import axios from 'axios'
import './request.js'

// 获取所有用户参与公益
export const userPublic = function () {
  return axios.get('/content/nice/userlist')
}

// 修改用户参与公益状态（已参与，已完成）
export const updateUserPublic = function (params) {
  return axios.put('/content/usernice/update', params)
}

// 获取所有公益事件
export const publicList = function () {
  return axios.get('/content/nice/list')
}

// 添加公益分类
export const addPublicCate = function (params) {
  return axios.post(`/content//nicefenlei/add/${params.name}`, params.filedata)
}

// 删除公益分类
export const deletePublicCate = function (params) {
  return axios.delete(`/content/nicefenlei/delete/${params}`)
}

const headers = { 'content-Type': 'application/json' }
// 添加公益事件
export const addPublic = function (params) {
  return axios.post(`/content/nice/add/${params.name}/${params.point}/${params.remark}/${params.parent}`, params.filedata)
}

// 修改公益事件
export const updatePublic = function (params) {
  return axios.put('/content/nice/update', params, { headers: headers })
}

// 删除公益事件
export const deletePublic = function (params) {
  return axios.delete(`/content/nice/delete/${params}`)
}
